package com.bmldyq.family.front.sysManager.controller;

import com.bmldyq.family.common.vo.AvailableResult;
import com.bmldyq.family.front.sysManager.service.CodeService;
import com.bmldyq.family.model.SysParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/sys/codes")
@Slf4j
public class SysCodeManagerController {

    @Autowired
    private CodeService codeService;

    @RequestMapping(value = "/getSysAll",method = RequestMethod.GET)
    @ResponseBody
    public AvailableResult<SysParam> getAllSysParam(){
        log.info("SysCodeManagerController.getAllSysParam ....");
        AvailableResult<SysParam> availableResult = codeService.getAllParam();
        if(availableResult.getCode().equals(HttpStatus.OK)){
            log.info("请求成功");
        }else{
            log.info("请求失败");
        }
        return availableResult;
    }

    @RequestMapping(value = "/get",method = RequestMethod.GET)
    @ResponseBody
    public AvailableResult<SysParam> get(){
        log.info("SysCodeManagerController.get ....");
        AvailableResult<SysParam> availableResult = codeService.getParam();
        if(availableResult.getCode().equals(HttpStatus.OK)){
            log.info("请求成功");
        }else{
            log.info("请求失败");
        }
        return availableResult;
    }

    @RequestMapping(value = "/get2",method = RequestMethod.GET)
    @ResponseBody
    public AvailableResult<SysParam> get2(){
        log.info("SysCodeManagerController.get2 ....");
        AvailableResult<SysParam> availableResult = codeService.get2();
        if(availableResult.getCode().equals(HttpStatus.OK)){
            log.info("请求成功");
        }else{
            log.info("请求失败");
        }
        return availableResult;
    }
}
